﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace DTO.Common
{
    [DataContract]
    public class Product
    {
        [DataMember] public int Code { get; set; }
        [DataMember] public int StockMin { get; set; }
        [DataMember] public int Stock { get; set; }
        [DataMember] public ProductType Type { get; set; }
        [DataMember] public string Designation { get; set; }
        [DataMember] public decimal Price { get; set; }
        [DataMember] public Supplier Supplier { get; set; }
        [DataMember] public bool Ordered { get; set; }


        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("Product:");
            builder.Append(string.Format("\tCode = {0}", Code));
            builder.Append(string.Format("\tStock = {0}", Stock));
            builder.Append(string.Format("\tType = {0}", Type));

            if (StockMin > 0)
                builder.Append(string.Format("\tStockMin = {0}", StockMin));

            if(Designation != null)
                builder.Append(string.Format("\tDesignation = {0}", Designation));
            
            if(Price > 0)
                builder.Append(string.Format("\tPrice = {0}", Price));

            if (Supplier != null)
                builder.Append(Supplier.ToString());

            if (Ordered)
                builder.Append(string.Format("\tOrdered = true"));

            return builder.ToString();
        }
    }
}
